|<$paratext><$pagenum>Interapplication CommunicationContents.Introduction to Interapplication Communication*Overview of Interapplication CommunicationCFigure 1-1 Principal methods of communication between applications Sharing Data Among Applications;Figure 1-2 Sharing data with the aid of the Edition Manager4Figure 1-3 A publisher, an edition, and a subscriber7Figure 1-4 Sharing dynamic data with other applications&Sending and Responding to Apple EventsYFigure 1-5 Sending and responding to Apple events with the aid of the Apple Event ManagerStandard Apple EventsHandling Apple EventsFigure 1-6 A Set Data event4Supporting AppleScript and Other Scripting Languages6Figure 1-7 How a scripting component executes a scriptScriptable Applications=Figure 1-8 A Set Data event sent during script execution Recordable Applications>Figure 1-9 Recording user actions in a factored application 0Applications That Manipulate and Execute ScriptsKFigure 1-10 Controlling an application’s own behavior by executing a scriptLFigure 1-11 Posting an invoice and updating a database by executing a scriptExchanging Message BlocksIntroduction to Apple EventsAbout Apple Events"Figure 3-1 An Open Documents event$Apple Events and Apple Event ObjectsFigure 3-2 A Get Data event %Apple Event Attributes and ParametersApple Event AttributesApple Event Parameters2Interpreting Apple Event Attributes and ParametersKFigure 3-3 Major attributes and direct parameter of an Open Documents eventDFigure 3-4 Major attributes and direct parameter of a Get Data event#Data Structures Within Apple EventsDescriptor RecordsQFigure 3-5 A descriptor record whose data handle refers to an unterminated stringKFigure 3-6 A descriptor record whose data handle refers to event class data$Keyword-Specified Descriptor RecordsjFigure 3-7 A keyword-specified descriptor record for the event class attribute of an Open Documents event Descriptor Lists2Figure 3-8 A descriptor list for a list of aliases9Figure 3-9 Data structures within an Open Documents eventResponding to Apple Events%Accepting and Processing Apple Events<Figure 3-10 Accepting and processing an Open Documents eventSFigure 3-11 The Apple Event Manager calling the handler for an Open Documents eventAbout Apple Event HandlersExtracting and Checking DataInteracting With the User6Performing the Requested Action and Returning a Result4Figure 3-12 Responding to an Open Documents event (Requesting Services Through Apple EventsCreating an Apple Event Record,Adding Apple Event Attributes and Parameters-Sending an Apple Event and Handling the Reply%Working With Object Specifier Records1Data Structures Within an Object Specifier Record=Figure 3-13 Data structures within an object specifier record:Figure 3-14 An object specifier record in a Get Data event)The Classification of Apple Event ObjectsObject Classes'Figure 3-15 Superclasses and subclassesProperties and ElementsOFigure 3-16 The object class inheritance hierarchy for the object class cWindowgFigure 3-17 An Apple event object of class cWord contained in an Apple event object of class cParagraphFinding Apple Event ObjectsAbout the Apple Event Manager /Supporting Apple Events as a Server Application/Supporting Apple Events as a Client ApplicationSupporting Apple Event Objects Supporting Apple Event RecordingResponding to Apple EventsHandling Apple EventsAccepting an Apple EventListing 4-1 A DoEvent procedure^Listing 4-2 A DoHighLevelEvent procedure for handling Apple events and other high-level events5Installing Entries in the Apple Event Dispatch Tables0Installing Entries for the Required Apple EventsgListing 4-3 Adding entries for the required Apple events to an application’s Apple event dispatch table?Installing Entries for Apple Events Sent by the Edition ManagervListing 4-4 Adding entries for Apple events sent by the Edition Manager to an application’s Apple event dispatch table!How Apple Event Dispatching Works"Handling the Required Apple EventsRequired Apple Events#Handling the Open Application Event4Listing 4-5 A handler for the Open Application event!Handling the Open Documents Event2Listing 4-6 A handler for the Open Documents event"Handling the Print Documents Event3Listing 4-7 A handler for the Print Documents event#Handling the Quit Application Event5Listing 4-8 A handler for the Quit Application event 1Handling Apple Events Sent by the Edition Manager#Handling the Create Publisher Event4Listing 4-9 A handler for the Create Publisher event"Getting Data Out of an Apple Event,Getting Data Out of an Apple Event Parameter Getting Data Out of an Attribute%Getting Data Out of a Descriptor List4Listing 4-10 Extracting items from a descriptor listWriting Apple Event HandlersHListing 4-11 A function that checks for a keyMissedKeywordAttr attributeReplying to an Apple EventIListing 4-12 Adding the keyErrorString parameter to the reply Apple event7Listing 4-13 Adding parameters to the reply Apple event(Disposing of Apple Event Data Structures(Writing and Installing Coercion Handlers@Coercion handling provided by the Apple Event Manager(continued)Interacting With the User=Setting the Client Application’s User Interaction Preferences=Setting the Server Application’s User Interaction PreferencesRequesting User Interaction2Listing 4-14 Using the AEInteractWithUser functionBFigure 4-1 A document with a button that triggers a Get Data event_Figure 4-2 A server application displaying a dialog box that requests information from the userCFigure 4-3 Handling user interaction with the kAEWaitReply flag setTFigure 4-4 Handling user interaction with the kAEWaitReply flag set (see Figure 4-3)YFigure 4-5 Handling user interaction with the kAEQueueReply flag set (see Figure 4-3) 'Reference to Responding to Apple Events/Data Structures Used by the Apple Event Manager.Descriptor Records and Related Data StructurespDescriptor types used by the Apple Event Manager (excluding those used with object specifier records)(continued)Apple Event Array Data Types'Routines for Responding to Apple Events5Creating and Managing the Apple Event Dispatch TablesDispatching Apple EventsMGetting Data or Descriptor Records from Apple Event Parameters and Attributes&Counting the Items in Descriptor Lists#Getting Items From Descriptor Lists3Getting Data and Descriptor Records From AE RecordsRequesting User Interaction/Requesting More Time to Respond to Apple Events,Suspending and Resuming Apple Event Handling<Getting the Sizes and Descriptor Types of Descriptor RecordsDeleting Descriptor Records*Deallocating Memory for Descriptor RecordsCoercing Descriptor Types:Creating and Managing the Coercion Handler Dispatch Tables9Creating and Managing the Special Handler Dispatch Tables1Getting Information About the Apple Event ManagerApplication-Defined Functions%Summary of Responding to Apple Events!Creating and Sending Apple EventsCreating an Apple Event#Adding Parameters to an Apple Event1Specifying Optional Parameters for an Apple EventHListing 5-1 Creating the optional keyword for the Create Publisher eventSpecifying a Target Address%Creating an Address Descriptor Record%Listing 5-2 Creating a target addressZListing 5-3 Specifying a target address in an Apple event by using the PPCBrowser function0Addressing an Apple Event for Direct DispatchingSending an Apple Event#Listing 5-4 Sending an Apple event Dealing With TimeoutsWriting an Idle FunctionListing 5-5 An idle function Writing a Reply Filter Function.Reference to Creating and Sending Apple Events.Routines for Creating and Sending Apple EventsCreating Apple Events+Creating and Duplicating Descriptor Records(Creating Descriptor Lists and AE Records Adding Items to Descriptor Lists0Adding Data and Descriptor Records to AE Records0Adding Parameters and Attributes to Apple EventsSending Apple EventsApplication-Defined Functions,Summary of Creating and Sending Apple Events/Resolving and Creating Object Specifier Records"Resolving Object Specifier RecordsIFigure 6-1 Resolving an object specifier record for a table in a document3Descriptor Records Used in Object Specifier RecordsObject Class ContainerNFigure 6-2 Nesting object specifier records that specify a container hierarchyKey FormKey Data;Standard descriptor types used with keyAEKeyData(continued)Key Data for a Property IDKey Data for an Object’s NameKey Data for Absolute PositionKey Data for Relative PositionKey Data for a Test;Keyword-specified descriptor records for typeCompDescriptor>Keyword-specified descriptor records for typeLogicalDescriptorQFigure 6-3 The container hierarchy for the first row in a table that meets a test>Figure 6-4 A logical descriptor record that specifies a test Key Data for a RangeWKeyword-specified descriptor records in a descriptor record of type typeRangeDescriptor9Installing Entries in the Object Accessor Dispatch TablesBInstalling Object Accessor Functions That Find Apple Event ObjectsiListing 6-1 Adding entries for object accessor functions that locate elements of different object classesmListing 6-2 Adding entries for one object accessor function that locates elements of different object classesfListing 6-3 Adding entries for object accessor functions that locate elements of the same object classiListing 6-4 Adding entries for object accessor functions that locate elements of different object classes9Installing Object Accessor Functions That Find Properties!Writing Object Accessor Functions?Writing Object Accessor Functions That Find Apple Event ObjectscListing 6-5 An object accessor function that locates Apple event objects of object class cDocument dListing 6-6 An object accessor function that locates Apple event objects of object class cParagraph _Listing 6-7 An object accessor function that locates Apple event objects of object class cWord eListing 6-8 An object accessor function that locates Apple event objects of the object class cWindow 6Writing Object Accessor Functions That Find PropertiesvListing 6-9 An object accessor function that finds any property identified by a token of descriptor type typeMyWindow Defining Tokens XFigure 6-5 Descriptor record for an application-defined token that identifies a documentnFigure 6-6 Descriptor record for an application-defined token that identifies the pbounds property of a windowHandling Whose Tests<Keyword-specified descriptor records for typeWhoseDescriptor]Figure 6-7 A container hierarchy for a server application supporting whose descriptor records7Keyword-specified descriptor records for typeWhoseRange!Writing Object Callback Functions#Writing an Object-Counting Function)Listing 6-10 An object-counting function %Writing an Object Comparison FunctionNListing 6-11 Object comparison function that compares two Apple event objects "Writing Marking Callback Functions!Creating Object Specifier RecordsDNesting object specifier records that describe a container hierarchy)Creating a Simple Object Specifier RecordIListing 6-12 Creating an object specifier record using CreateObjSpecifierIListing 6-13 Using CreateObjSpecifier in an application-defined function "Specifying the Container Hierarchy-Listing 6-14 Specifying a document container *Listing 6-15 Specifying a table container Specifying a PropertySpecifying a Relative Position*Creating a Complex Object Specifier RecordSpecifying a TestIObject specifier record for the first row in a document that meets a test/Logical descriptor record that specifies a testLListing 6-16 Creating an object specifier record with the key form formName 5Listing 6-17 Creating a comparison descriptor record 2Listing 6-18 Creating a logical descriptor record 8Listing 6-19 Creating a complex object specifier record Specifying a RangeA range descriptor record0Listing 6-20 Creating a range descriptor record <Reference to Resolving and Creating Object Specifier Records0Data Structures Used in Object Specifier RecordsGKeyword-specified descriptor records for typeObjectSpecifier(continued)<Routines for Resolving and Creating Object Specifier Records'Initializing the Object Support Library?Setting Object Accessor Functions and Object Callback Functions8Getting, Calling, and Removing Object Accessor Functions"Resolving Object Specifier RecordsDeallocating Memory for Tokens!Creating Object Specifier RecordsApplication-Defined FunctionsObject Accessor FunctionsObject Callback Functions:Summary of Resolving and Creating Object Specifier RecordsIntroduction to Scripting&About Scripts and Scripting ComponentsScript Editors and Script Files:Figure 7-1 A script window in the Toy Surprise application0Scripting Components and Scriptable Applications;Figure 7-2 How the AppleScript component executes a script :Scripting Components and Applications That Execute ScriptsPFigure 7-3 How an application uses the AppleScript component to execute a script"Making Your Application Scriptable'About Apple Event Terminology Resources,How AppleScript Uses Terminology InformationtFigure 7-4 Role of the \qaete\q and \qaeut\q resources when the AppleScript component compiles and executes a scriptuFigure 7-5 Role of the \qaete\q and \qaeut\q resources when the AppleScript component records and decompiles a script*Dynamic Loading of Terminology Information"Making Your Application Recordable"Manipulating and Executing Scripts3Compiling, Saving, Modifying, and Executing Scripts/Using a Script Context to Handle an Apple EventGFigure 7-6 Using a handler in a script context to handle an Apple event!Apple Event Terminology Resources9Defining Terminology for Use by the AppleScript ComponentOTable 8-1 Syntax for AppleScript arguments that correspond to direct parameterscTable 8-2 Syntax for AppleScript arguments that correspond to insertion location descriptor records.Structure of Apple Event Terminology Resources6Table 8-3 Structure of the 'aeut' and 'aete' resources?Listing 8-1 Resource type declaration for the 'aeut' resource 6Creating an Apple Event Terminology Extension Resource-Supporting Standard Suites Without ExtensionsfListing 8-2 Rez input for an 'aete' resource that lists the Required and Core suites in their entiretyExtending the Standard SuitespListing 8-3 Rez input for an 'aete' resource that extends the definitions of the Required, Core, and Text suitesSupporting Subsets of SuitesSupporting New SuitesHandling the Get AETE Event,Listing 8-4 A handler for the Get AETE event.Reference to Apple Event Terminology Resources4Figure 8-1 Structure of an 'aeut' or 'aete' resource3Header Data for an Apple Event Terminology ResourceGFigure 8-2 Structure of the header data in an 'aeut' or 'aete' resource7Suite Data for an Apple Event User Terminology ResourceBFigure 8-3 Structure of suite data in an 'aeut' or 'aete' resource
Event DataBFigure 8-4 Structure of event data in an 'aeut' or 'aete' resourceQFigure 8-5 Structure of additional parameter data in an 'aeut' or 'aete' resourceObject Class DataKFigure 8-6 Structure of object class data in an 'aeut' or 'aete' resource. FFigure 8-7 Structure of property data in an 'aeut' or 'aete' resource.KFigure 8-8 Structure of element class data in an 'aeut' or 'aete' resource.Comparison Operator DataRFigure 8-9 Structure of comparison operator data in an 'aeut' or 'aete' resource. Enumeration and Enumerator Data JFigure 8-10 Structure of enumeration data in an 'aeut' or 'aete' resource.IFigure 8-11 Structure of enumerator data in an 'aeut' or 'aete' resource.The Scripting Size ResourceAListing 8-5 Resource type declaration for the \qscsz\q resource. Recording Apple EventsAbout Recordable Applications(Factoring Your Application for Recording.Factoring the Quit Command and the New Command]Listing 9-1 A function used by a factored application to send itself a Quit Application eventXListing 9-2 A routine used by a factored application to handle a Quit Application event [Listing 9-3 A routine used by a factored application to send itself a Create Element event HListing 9-4 The Create Element event handler for a factored application +Sending Apple Events Without Executing ThemOListing 9-5 A routine used by a factored application to handle window movement What to RecordRecording User Actions'Recording the Selection of Text ObjectsRecording Insertion PointsRecording Typing*Recording the Selection of Nontext ObjectsIdentifying Objects%Moving the Selection During Recording(Recording Interactions With Dialog Boxes:Special Considerations for Scripts that Run AsynchronouslyHow Apple Event Recording WorksScripting Components#Connecting to a Scripting ComponentUListing 10-1 Locating a scripting component that supports specific optional routines "Using Scripting Component Routines#Compiling and Executing Source Data>Listing 10-2 A routine that compiles and executes source data ^Listing 10-3 A procedure that uses OSAScriptError to get information about an execution error Saving Script DataStorage Formats for Script Data0Figure 10-1 A generic storage descriptor record :Figure 10-2 A component-specific storage descriptor record'Resource and File Types for Script Data!Loading and Executing Script Data|Listing 10-4 A routine that loads and executes script data previously saved as data for a generic storage descriptor record +Modifying and Recompiling a Compiled ScriptUListing 10-5 A routine that displays a compiled script for editing and recompiles it 4Executing an Apple Event Handler in a Script ContextMListing 10-6 A general Apple event handler that uses the OSADoEvent function (Supplying an Alternative Active Function/Supplying Alternative Create and Send FunctionsAlternative Create FunctionsAlternative Send FunctionsRecording ScriptsWriting a Scripting ComponentScripting Components ReferenceData Structures%Required Scripting Component RoutinesSaving and Loading Script Data"Executing and Disposing of Scripts&Setting and Getting Script Information Manipulating the Active Function%Optional Scripting Component RoutinesCompiling ScriptsGetting Source DataCoercing Script Values*Manipulating the Create and Send FunctionsRecording ScriptsExecuting Scripts In One StepManipulating Dialects1Executing Apple Event Handlers in Script ContextsAppleScript Component RoutinesInitializing AppleScript*Getting and Setting Styles for Source Data%Routines Used by Scripting Components<Manipulating Trailers for Generic Storage Descriptor RecordsApplication-Defined FunctionsSummary of Scripting ComponentsIndex